{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "aa680e26",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (1854807487.py, line 12)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [1]\u001b[1;36m\u001b[0m\n\u001b[1;33m    print(\"商品编号:\"+str(i),product_list[i])\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "product_list = [\n",
    "    [\"自行车\",300],\n",
    "    [\"书本\",90],\n",
    "    [\"衣服\",100],\n",
    "    [\"水杯\", 80]\n",
    "]\n",
    "shopping_car = [] \n",
    "Alipay = input(\"请输入金额:\")\n",
    "while True:\n",
    "    print(\"-------商品列表---------\")\n",
    "    for i in range(4):\n",
    "    print(\"商品编号:\"+str(i),product_list[i])\n",
    "user_chioce = input(\"请输入商品编号:\")\n",
    "if user_chioce.isdigit():\n",
    "    #判断钱够不够，商品是谁？==> product_list[user_chioce][1]\n",
    "    if Alipay >= product_list[int(user_chioce)][1]:\n",
    "        Alipay = Alipay - product_list[int(user_chioce)][1] # 买完商品剩余的钱\n",
    "        shopping_car.append(product_list[int(user_chioce)])\n",
    "        print(\"您购买的商品已添加到购物车\")\n",
    "    else:\n",
    "        print(\"您的余额不足，请更换支付方式\")\n",
    "    # 情景2：用户输入\"q\",退出购买\n",
    "    elif user_chioce == \"q\":\n",
    "        print(\"您的购物车\",shopping_car)\n",
    "        print(\"您的余额还有：\",Alipay)\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f8c9b6c3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "29e0696c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
